<?php
if (!defined('PRODUCTION')) die ("This resource is unavailable and/or is a server end-point");

class Anchor
{
    public $aTag;
    public $link;
    public $target;
    public $text;


    function __construct ( $params ) {
        $this->aTag = new DOMDocument( );
        $this->assign_anchor_params( $params );
    }

    public function assign_anchor_params( $params ) {
        $this->link = $params['link'];
        $this->target = $params['target'];
        $this->text = $params['text'];
        $this->create_tag();
    }

    public function create_tag() {
        $element = $this->aTag->createElement( 'a' );
        $element->setAttribute( 'href', $this->link );
        $element->setAttribute( 'target', $this->target);
        $this->aTag->appendChild( $this->text );

        return $this->aTag;
    }

    public function createElement ( $nodeName,$nodeValue=null ) {
      return $this->document->createElement($nodeName, $nodeValue );
    }
}
?>